import * as THREE from "three";
import gsap from "gsap";

var scene;
var debug;
var mesh;
function init(xscene, xdebug) {
  scene = xscene;
  debug = xdebug;

  setMesh();
}
function setMesh() {
  const geometry = new THREE.BoxGeometry(5, 5, 5); // 创建几何体
  const material = new THREE.MeshBasicMaterial({ color: 0x105c0a }); //创建材质
  mesh = new THREE.Mesh(geometry, material); // 将材质额几何体结合为物体
  mesh.position.set(0, 0, 0); //向相机中添加物体
  scene.add(mesh); // 将物体添加进场景

  rotateZ()
  setDebug(mesh);
}

function rotateZ(){
    gsap.to( mesh.rotation,
    {
        y: 2 * Math.PI,
        duration: 10,
        repeat: -1,
        ease: "power1.inOut" 
    })
}

function setDebug(mesh) {
  var Folder01 = debug.addFolder("测试");
  console.log(mesh);
  Folder01.add(mesh.position, "x");
  Folder01.addColor(mesh.material, "color");
}

export { init };
